from utils.BaseHTTPRequest import BaseHTTPRequest


class JuheClient(BaseHTTPRequest):
    """Juhe服务API类 - 无认证"""

    def __init__(self):
        """
        初始化Juhe API客户端
        """
        # 不使用任何认证处理器
        super().__init__(base_url="http://apis.juhe.cn", auth_handler=None)
        self.key = "72882230ea9993a999a6dbcd5234594a"
        
    def _set_key(self,data:dict):
        data["key"] = self.key
    
    def get_goodbook_catalog(self, params: dict) -> dict:
        """获取好书分类"""
        self._set_key(params)
        return self.get(endpoint = "/goodbook/catalog", params = params)


juhe_client = JuheClient()


if __name__ == "__main__":
    juhe_client.get_goodbook_catalog({"dtype":"json"})